
package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

/**
 * @author lcx
 *
 */
public class Seri implements java.io.Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int num=400;
	private String name="liu";
	private transient String tag="a";
	private static int count=0;
	private static Seri instance=new Seri();

	private static Seri getInstance()
	{
		return instance;
	} 


	public static void main(String[] args) throws Exception
	{
		Seri sr=Seri.getInstance();
		sr.num=300;
		sr.name="chen";
		sr.tag="b";
		System.out.println("**"+sr.hashCode());
		FileOutputStream fos=new FileOutputStream("a.txt");
		ObjectOutputStream oos=new ObjectOutputStream(fos);
		oos.writeObject(sr);
		FileInputStream fis=new FileInputStream("a.txt");
		ObjectInputStream ois=new ObjectInputStream(fis);
		Seri sr1=(Seri) ois.readObject();
		System.out.println("num="+sr1.num);
		System.out.println("name="+sr1.name);
		System.out.println("tag="+sr1.tag);
		System.out.println("count="+sr1.count);
		System.out.println("**"+sr1.hashCode());
	}

}
